package com.wemei.auto.ui.widget.jsbridge;

import android.os.Handler;

import com.wemei.auto.ui.widget.X5WebView;

import java.lang.ref.WeakReference;

/**
 * 注入基类
 *
 * @author Administrator on 2017/3/1 0001.
 */

public class BaseInjected {
    protected Handler handler;
    protected WeakReference<X5WebView> webViewWeak;

    public BaseInjected(X5WebView webView) {
        this.webViewWeak = new WeakReference<>(webView);
    }

    public void onDestroy() {
        if (handler != null) {
            handler.removeCallbacks(null);
        }
        webViewWeak.clear();
    }

    public void onSaveInstanceState() {
    }

    public boolean isNotNullWebView() {
        return webViewWeak != null && webViewWeak.get() != null;
    }

    public void setHandler(Handler handler) {
        this.handler = handler;
    }
}
